<!DOCTYPE html>
<html lang="zh-Hans">
<head>

    <!--[if lt IE 9]>
        <style>body {display: none; background: none !important} </style>
        <meta http-equiv="Refresh" Content="0; url=//outdatedbrowser.com/" />
    <![endif]-->

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no" />
<meta name="author" content="min peng" />



<meta name="description" content="git使用指南">
<meta property="og:type" content="article">
<meta property="og:title" content="git使用指南">
<meta property="og:url" content="https://minpeng.github.io/2019/11/05/git使用指南/index.html">
<meta property="og:site_name" content="Pengm">
<meta property="og:description" content="git使用指南">
<meta property="og:image" content="https://imgconvert.csdnimg.cn/aHR0cHM6Ly9pbWcubXVrZXdhbmcuY29tLzU5YzMxZTQ0MDAwMTNiYzkxMTcyMDM0MC5wbmc?x-oss-process=image/format,png">
<meta property="og:image" content="https://imgconvert.csdnimg.cn/aHR0cHM6Ly93d3cubGlhb3h1ZWZlbmcuY29tL2ZpbGVzL2F0dGFjaG1lbnRzLzkxODkyMTU0MDM1NTg3Mi8w?x-oss-process=image/format,png">
<meta property="og:image" content="https://imgconvert.csdnimg.cn/aHR0cHM6Ly93d3cubGlhb3h1ZWZlbmcuY29tL2ZpbGVzL2F0dGFjaG1lbnRzLzkxODkyMTU2MjIzNjE2MC8w?x-oss-process=image/format,png">
<meta property="og:image" content="https://minpeng.github.io//image/eclipse/commit.png">
<meta property="og:image" content="https://minpeng.github.io//image/eclipse/commit-info.png">
<meta property="og:image" content="https://minpeng.github.io//image/eclipse/push.png">
<meta property="og:image" content="https://minpeng.github.io//image/eclipse/pull.png">
<meta property="og:image" content="https://minpeng.github.io//image/eclipse/branch.png">
<meta property="og:image" content="https://minpeng.github.io//image/eclipse/merage.png">
<meta property="og:image" content="https://minpeng.github.io//image/idea/commit.png">
<meta property="og:image" content="https://minpeng.github.io//image/idea/commit-info.png">
<meta property="og:image" content="https://minpeng.github.io//image/idea/pull-push.png">
<meta property="og:image" content="https://minpeng.github.io//image/idea/pull-push2.png">
<meta property="og:image" content="https://minpeng.github.io//image/idea/branch1.png">
<meta property="og:image" content="https://minpeng.github.io//image/idea/branch2.png">
<meta property="og:image" content="https://minpeng.github.io//image/idea/branchMerge.png">
<meta property="og:image" content="https://minpeng.github.io//image/idea/conflict.png">
<meta property="og:image" content="https://minpeng.github.io//image/gitlab/create-group.png">
<meta property="og:image" content="https://minpeng.github.io//image/gitlab/add-members.png">
<meta property="og:image" content="https://minpeng.github.io//image/gitlab/create-project.png">
<meta property="og:image" content="https://minpeng.github.io//image/gitlab/add-project-members.png">
<meta property="og:updated_time" content="2019-11-06T12:23:20.798Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="git使用指南">
<meta name="twitter:description" content="git使用指南">
<meta name="twitter:image" content="https://imgconvert.csdnimg.cn/aHR0cHM6Ly9pbWcubXVrZXdhbmcuY29tLzU5YzMxZTQ0MDAwMTNiYzkxMTcyMDM0MC5wbmc?x-oss-process=image/format,png">

<link rel="apple-touch-icon" href= "/apple-touch-icon.png">


    <link rel="alternate" href="/atom.xml" title="Pengm" type="application/atom+xml">



    <link rel="shortcut icon" href="/favicon.png">



    <link href="//cdn.bootcss.com/animate.css/3.5.1/animate.min.css" rel="stylesheet">





    <script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
    <link href="//cdn.bootcss.com/pace/1.0.2/themes/blue/pace-theme-minimal.css" rel="stylesheet">


<link rel="stylesheet" href="/css/style.css">



<link href="//cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">


<title>git使用指南 | Pengm</title>

<script src="//cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>

<script>
    var yiliaConfig = {
        fancybox: undefined,
        animate: true,
        isHome: false,
        isPost: true,
        isArchive: false,
        isTag: false,
        isCategory: false,
        fancybox_js: "//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.js",
        scrollreveal: "//cdn.bootcss.com/scrollReveal.js/3.1.4/scrollreveal.min.js",
        search: true
    }
</script>


    <script> yiliaConfig.jquery_ui = [false]; </script>



    <script> yiliaConfig.rootUrl = "\/";</script>





    <script>
        var _hmt = _hmt || [];
        (function() {
            var hm = document.createElement("script");
            hm.src = "//hm.baidu.com/hm.js?b3aa41a56e6fde6d00c616ac89493f29";
            var s = document.getElementsByTagName("script")[0]; 
            s.parentNode.insertBefore(hm, s);
        })();
    </script>


</head>
<body>
  <div id="container">
    <div class="left-col">
    <div class="overlay"></div>
<div class="intrude-less">
    <header id="header" class="inner">
        <a href="/" class="profilepic">
            <img src="/img/avatar.png" class="animated zoomIn">
        </a>
        <hgroup>
          <h1 class="header-author"><a href="/">min peng</a></h1>
        </hgroup>

        
        <p class="header-subtitle">Pengm blog</p>
        

        
            <form id="search-form">
            <input type="text" id="local-search-input" name="q" placeholder="search..." class="search form-control" autocomplete="off" autocorrect="off" searchonload="false" />
            <i class="fa fa-times" onclick="resetSearch()"></i>
            </form>
            <div id="local-search-result"></div>
            <p class='no-result'>No results found <i class='fa fa-spinner fa-pulse'></i></p>
        


        
            <div id="switch-btn" class="switch-btn">
                <div class="icon">
                    <div class="icon-ctn">
                        <div class="icon-wrap icon-house" data-idx="0">
                            <div class="birdhouse"></div>
                            <div class="birdhouse_holes"></div>
                        </div>
                        <div class="icon-wrap icon-ribbon hide" data-idx="1">
                            <div class="ribbon"></div>
                        </div>
                        
                        <div class="icon-wrap icon-link hide" data-idx="2">
                            <div class="loopback_l"></div>
                            <div class="loopback_r"></div>
                        </div>
                        
                        
                        <div class="icon-wrap icon-me hide" data-idx="3">
                            <div class="user"></div>
                            <div class="shoulder"></div>
                        </div>
                        
                    </div>
                    
                </div>
                <div class="tips-box hide">
                    <div class="tips-arrow"></div>
                    <ul class="tips-inner">
                        <li>菜单</li>
                        <li>标签</li>
                        
                        <li>友情链接</li>
                        
                        
                        <li>关于我</li>
                        
                    </ul>
                </div>
            </div>
        

        <div id="switch-area" class="switch-area">
            <div class="switch-wrap">
                <section class="switch-part switch-part1">
                    <nav class="header-menu">
                        <ul>
                        
                            <li><a href="/">主页</a></li>
                        
                            <li><a href="/archives/">所有文章</a></li>
                        
                            <li><a href="/tags/">标签云</a></li>
                        
                            <li><a href="/about/">关于我</a></li>
                        
                        </ul>
                    </nav>
                    <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" href="mailto:pengmin3@163.com" title="Email"></a>
                            
                                <a class="fa GitHub" href="https://github.com/minpeng" title="GitHub"></a>
                            
                                <a class="fa RSS" href="/atom.xml" title="RSS"></a>
                            
                                <a class="fa CSDN" href="http://blog.csdn.net/u010742049" title="CSDN"></a>
                            
                        </ul>
                    </nav>
                </section>
                
                
                <section class="switch-part switch-part2">
                    <div class="widget tagcloud" id="js-tagcloud">
                        <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/HBase/">HBase</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Linux/">Linux</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Mysql/">Mysql</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/SpringBoot/">SpringBoot</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/angular/">angular</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/git/">git</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hexo/">hexo</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/java/">java</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/memcahce/">memcahce</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/python/">python</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/quill/">quill</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/scala/">scala</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/scrapy/">scrapy</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/shiro/">shiro</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/spark/">spark</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/spring/">spring</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/stream/">stream</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/yelee/">yelee</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/系统架构/">系统架构</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/读书笔记/">读书笔记</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/随笔/">随笔</a></li></ul>
                    </div>
                </section>
                
                
                
                <section class="switch-part switch-part3">
                    <div id="js-friends">
                    
                      <a class="main-nav-link switch-friends-link" href="https://hexo.io">Hexo</a>
                    
                      <a class="main-nav-link switch-friends-link" href="https://pages.github.com/">GitHub</a>
                    
                      <a class="main-nav-link switch-friends-link" href="http://moxfive.xyz/">MOxFIVE</a>
                    
                    </div>
                </section>
                

                
                
                <section class="switch-part switch-part4">
                
                    <div id="js-aboutme">一个爱运动不是太宅的技术大男孩</div>
                </section>
                
            </div>
        </div>
    </header>                
</div>
    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
      <div class="overlay">
          <div class="slider-trigger"></div>
          <h1 class="header-author js-mobile-header hide"><a href="/" title="回到主页">min peng</a></h1>
      </div>
    <div class="intrude-less">
        <header id="header" class="inner">
            <a href="/" class="profilepic">
                <img src="/img/avatar.png" class="animated zoomIn">
            </a>
            <hgroup>
              <h1 class="header-author"><a href="/" title="回到主页">min peng</a></h1>
            </hgroup>
            
            <p class="header-subtitle">Pengm blog</p>
            
            <nav class="header-menu">
                <ul>
                
                    <li><a href="/">主页</a></li>
                
                    <li><a href="/archives/">所有文章</a></li>
                
                    <li><a href="/tags/">标签云</a></li>
                
                    <li><a href="/about/">关于我</a></li>
                
                <div class="clearfix"></div>
                </ul>
            </nav>
            <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" target="_blank" href="mailto:pengmin3@163.com" title="Email"></a>
                            
                                <a class="fa GitHub" target="_blank" href="https://github.com/minpeng" title="GitHub"></a>
                            
                                <a class="fa RSS" target="_blank" href="/atom.xml" title="RSS"></a>
                            
                                <a class="fa CSDN" target="_blank" href="http://blog.csdn.net/u010742049" title="CSDN"></a>
                            
                        </ul>
            </nav>
        </header>                
    </div>
    <link class="menu-list" tags="标签" friends="友情链接" about="关于我"/>
</nav>
      <div class="body-wrap"><article id="post-git使用指南" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2019/11/05/git使用指南/" class="article-date">
      <time datetime="2019-11-05T14:38:12.000Z" itemprop="datePublished">2019-11-05</time>
</a>


    </div>
  
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      git使用指南
    </h1>
  

      </header>
      
      <div class="article-info article-info-post">
        
    <div class="article-category tagcloud">
    <a class="article-category-link" href="/categories/git/">git</a>
    </div>


        
    <div class="article-tag tagcloud">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/git/">git</a></li></ul>
    </div>

        <div class="clearfix"></div>
      </div>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <contents>

<h2 id="git-使用指南"><a href="#git-使用指南" class="headerlink" title="git 使用指南"></a>git 使用指南</h2><h3 id="git-介绍"><a href="#git-介绍" class="headerlink" title="git 介绍"></a>git 介绍</h3><blockquote>
<p>C 语言编写的一个分布式版本控制系统</p>
</blockquote>
<ol>
<li>git 工作原理</li>
</ol>
<p><img src="https://imgconvert.csdnimg.cn/aHR0cHM6Ly9pbWcubXVrZXdhbmcuY29tLzU5YzMxZTQ0MDAwMTNiYzkxMTcyMDM0MC5wbmc?x-oss-process=image/format,png" alt="avatar"></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"></div><div class="line">Workspace：工作区</div><div class="line">Index / Stage：暂存区</div><div class="line">Repository：仓库区（或本地仓库）</div><div class="line">Remote：远程仓库</div></pre></td></tr></table></figure>
<p>2.git 和 svn 区别</p>
<ul>
<li>svn 集中式</li>
</ul>
<p><img src="https://imgconvert.csdnimg.cn/aHR0cHM6Ly93d3cubGlhb3h1ZWZlbmcuY29tL2ZpbGVzL2F0dGFjaG1lbnRzLzkxODkyMTU0MDM1NTg3Mi8w?x-oss-process=image/format,png" alt="avatar"></p>
<ul>
<li>git 分布式</li>
</ul>
<p><img src="https://imgconvert.csdnimg.cn/aHR0cHM6Ly93d3cubGlhb3h1ZWZlbmcuY29tL2ZpbGVzL2F0dGFjaG1lbnRzLzkxODkyMTU2MjIzNjE2MC8w?x-oss-process=image/format,png" alt="avatar"></p>
<blockquote>
<p>为什么说 git 是分布式的</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">这里的“分布式”是相对于“集中式”来说的。把数据集中保存在服务器节点，所有的客户节点都从服务节点获取数据的版本控制系统叫做集中式版本控制系统，比如svn就是典型的集中式版本控制系统。</div><div class="line"></div><div class="line">与之相对，git的数据不止保存在服务器上，同时也完整的保存在本地计算机上，所以我们称git为分布式版本控制系统。</div><div class="line"></div><div class="line">git的这种特性带来许多便利，比如你可以在完全离线的情况下使用git，随时随地提交项目更新，而且你不必为单点故障过分担心，即使服务器宕机或数据损毁，也可以用任何一个节点上的数据恢复项目，因为每一个开发节点都保存着完整的项目文件镜像。</div></pre></td></tr></table></figure>
<blockquote>
<p>git 和 svn 差异对比</p>
</blockquote>
<table>
<thead>
<tr>
<th style="text-align:left">差异点</th>
<th style="text-align:left">svn</th>
<th style="text-align:left">git</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">系统特点</td>
<td style="text-align:left">1.集中式版本控制系统（文档管理很方便) <br> 2.企业内部并行集中开发 <br>3.windows 系统上开发推荐使用<br>4.克隆一个拥有将近一万个提交(commit),五个分支,每个分支有大约 1500 个文件，用时将近一个小时</td>
<td style="text-align:left">1.分布式系统（代码管理很方便）<br>2.开源项目开发<br>3.mac,Linux 系统上开发推荐使用<br>4.克隆一个拥有将近一万个提交(commit),五个分支,每个分支有大约 1500 个文件，用时 1 分钟</td>
</tr>
<tr>
<td style="text-align:left">灵活性</td>
<td style="text-align:left">1.搭载 svn 的服务器出现故障，无法与之交互<br>2.所有的 svn 操作都需要中央仓库交互（例：拉分支，看日志等）</td>
<td style="text-align:left">1.可以单机操作，git 服务器故障也可以在本地 git 仓库工作<br>2.除了 push 和 pull（或 fetch）操作，其他都可以在本地操作<br>3.根据自己开发任务任意在本地创建分支 4.日志都是在本地查看，效率较高</td>
</tr>
<tr>
<td style="text-align:left">安全性</td>
<td style="text-align:left">较差，定期备份，并且是整个 svn 都得备份</td>
<td style="text-align:left">较高，每个开发者的本地就是一套完整版本库，记录着版本库的所有信息（gitlab 集成了备份功能）</td>
</tr>
<tr>
<td style="text-align:left">分支方面</td>
<td style="text-align:left">1.拉分支更像是 copy 一个路径<br>2.可针对任何子目录进行 branch<br>3.拉分支的时间较慢，因为拉分支相当于 copy<br>4.创建完分支后，影响全部成员，每个人都会拥有这个分支<br>5.多分支并行开发较重（工作较多而且繁琐）</td>
<td style="text-align:left">1.我可以在 Git 的任意一个提交点（commit point）开启分支！（git checkout -b newbranch HashId）<br>2.拉分支时间较快，因为拉分支只是创建文件的指针和 HEAD<br>3.自己本地创建的分支不会影响其他人<br>4.比较适合多分支并行开发<br>5.git checkout hash 值(切回之前的版本，无需版本回退)</td>
</tr>
<tr>
<td style="text-align:left">版本控制</td>
<td style="text-align:left">1.保存前后变化的差异数据，作为版本控制<br>2.版本号进行控制，每次操作都会产生一个高版本号（svn 的全局版本号，这是 svn 一个较大的特点，git 是 hash 值）</td>
<td style="text-align:left">1.git 只关心文件数据的整体发生变化，更像是把文件做快照，文件没有改变时，分支只想这个文件的指针不会改变，文件发生改变，指针指向新版本<br>\2. 40 位长的哈希值作为版本号，没有先后之分</td>
</tr>
<tr>
<td style="text-align:left">工作流程</td>
<td style="text-align:left">1.每次更改文件之前都得 update 操作，有的时候修改过程中这个文件有更新，commit 不会成功<br>2.有冲突，会打断提交动作（冲突解决是一个提交速度的竞赛：手快者，先提交，平安无事；手慢者，后提交，可能遇到麻烦的冲突解决。）</td>
<td style="text-align:left">1.开始工作前进行 fetch 操作，完成开发工作后 push 操作，有冲突解决冲突<br>2.git 的提交过程不会被打断，有冲突会标记冲突文件</td>
</tr>
<tr>
<td style="text-align:left">学习成本</td>
<td style="text-align:left">使用起来更方便，svn 对中文支持好，操作简单，适用于大众</td>
<td style="text-align:left">更在乎效率而不是易用性，成本较高（有很多独有的命令，rebase，远程仓库交互的命令，等等）</td>
</tr>
<tr>
<td style="text-align:left">权限管理</td>
<td style="text-align:left">svn 的权限管理相当严格，可以按组、个人针对某个子目录的权限控制（每个目录下都会有个.svn 的隐藏文件）</td>
<td style="text-align:left">git 没有严格的权限管理控制，只有账号角色划分</td>
</tr>
</tbody>
</table>
<h3 id="git-常用命令"><a href="#git-常用命令" class="headerlink" title="git 常用命令"></a>git 常用命令</h3><ol>
<li>初始化一个 git 仓库：git init</li>
<li>克隆仓库：git clone <url></url></li>
<li>添加文件（提交到缓存区）：git add <file></file></li>
<li>提交文件（提交到 HEAD）：git commit -m <message></message></li>
<li>推送改动(提交到远程仓库)：git push orgin <branch_name></branch_name></li>
<li>查看 git 仓库状态：git status</li>
<li>查看修改内容：git diff</li>
<li>查看提交日志：git log</li>
<li>回复版本：git reset –hard <commit_id></commit_id></li>
<li>创建分支：git branch <branch_name></branch_name></li>
<li>切换分支: git check <branch_name> /git switch <branch_name></branch_name></branch_name></li>
<li>查看分支：git branch</li>
<li>合并分支：git merge <branch_name></branch_name></li>
<li>删除分支：git branch -d <branch_name></branch_name></li>
<li>查看远程库信息：git remore -v</li>
<li>显示标签：git tag</li>
<li>新建标签：git tag <tag_name></tag_name></li>
<li>新建带备注的标签：git tag -a <tag_name> -m <tag_message></tag_message></tag_name></li>
<li>给某个 commit 答标签：git tag -a <tag_name> <commit_id> -m <tag_message></tag_message></commit_id></tag_name></li>
</ol>
<h3 id="tag-和-branche-的区别"><a href="#tag-和-branche-的区别" class="headerlink" title="tag 和 branche 的区别"></a>tag 和 branche 的区别</h3><ul>
<li><p>tag 对应某次 commit, 是一个点，是不可移动的（类似里程碑）</p>
</li>
<li><p>branch 对应一系列 commit，是很多点连成的一根线，有一个 HEAD 指针，是可以依靠 HEAD 指针移动的</p>
</li>
</ul>
<blockquote>
<p>git 有 commit，为什么还要引入 tag？</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line"></div><div class="line">&quot;请把上周一的那个版本打包发布，commit号是6a5819e…&quot;</div><div class="line"></div><div class="line">&quot;一串乱七八糟的数字不好找！&quot;</div><div class="line"></div><div class="line">如果换一个办法：</div><div class="line"></div><div class="line">&quot;请把上周一的那个版本打包发布，版本号是v1.2&quot;</div><div class="line"></div><div class="line">&quot;好的，按照tag v1.2查找commit就行！&quot;</div><div class="line"></div><div class="line">所以，tag就是一个让人容易记住的有意义的名字，它跟某个commit绑在一起。</div></pre></td></tr></table></figure>
<h3 id="工作流程"><a href="#工作流程" class="headerlink" title="工作流程"></a>工作流程</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">1.对代码进行修改</div><div class="line">2.完成了某项功能，提交（commit，只是提交到本地代码库），1-2可以反复进行，直到觉得可以推送到服务器上时，执行3</div><div class="line">3.拉取（pull，或者用获取 fetch 然后再手动合并 merge）</div><div class="line">4.如果存在冲突，解决冲突</div><div class="line">5.推送（push），将数据提交到服务器上的代码库</div></pre></td></tr></table></figure>
<h3 id="Eclipse-使用-git"><a href="#Eclipse-使用-git" class="headerlink" title="Eclipse 使用 git"></a>Eclipse 使用 git</h3><blockquote>
<p>右键-&gt;team</p>
</blockquote>
<ul>
<li><p>commit</p>
<p><img src="https://minpeng.github.io//image/eclipse/commit.png" alt="commit"></p>
<p><img src="https://minpeng.github.io//image/eclipse/commit-info.png" alt="commit"></p>
</li>
<li><p>push</p>
<p><img src="https://minpeng.github.io//image/eclipse/push.png" alt="commit"></p>
</li>
<li><p>pull</p>
<p><img src="https://minpeng.github.io//image/eclipse/pull.png" alt="pull"></p>
</li>
<li><p>分支</p>
<p><img src="https://minpeng.github.io//image/eclipse/branch.png" alt="branch"></p>
</li>
<li><p>合并</p>
<p><img src="https://minpeng.github.io//image/eclipse/merage.png" alt="merage"></p>
</li>
</ul>
<h3 id="idea-使用-git"><a href="#idea-使用-git" class="headerlink" title="idea 使用 git"></a>idea 使用 git</h3><ul>
<li><p>commit</p>
<p><img src="https://minpeng.github.io//image/idea/commit.png" alt="commit"></p>
<p><img src="https://minpeng.github.io//image/idea/commit-info.png" alt="commit"></p>
</li>
<li><p>push/pull</p>
<p><img src="https://minpeng.github.io//image/idea/pull-push.png" alt="commit"></p>
<p><img src="https://minpeng.github.io//image/idea/pull-push2.png" alt="commit"></p>
</li>
<li><p>分支</p>
<p><img src="https://minpeng.github.io//image/idea/branch1.png" alt="branch1"></p>
<p><img src="https://minpeng.github.io//image/idea/branch2.png" alt="branch1"></p>
</li>
<li><p>合并分支</p>
<p><img src="https://minpeng.github.io//image/idea/branchMerge.png" alt="branch1"></p>
</li>
<li><p>解决冲突</p>
<p><img src="https://minpeng.github.io//image/idea/conflict.png" alt="branch1"></p>
</li>
</ul>
<h3 id="gitlab-项目管理"><a href="#gitlab-项目管理" class="headerlink" title="gitlab 项目管理"></a>gitlab 项目管理</h3><ol>
<li><p>创建项目组</p>
<p><img src="https://minpeng.github.io//image/gitlab/create-group.png" alt="创建项目组"></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">私有库：只有被赋予权限的用户可见</div><div class="line">内部库：登录用户可以下载</div><div class="line">公开库：所有人可以下载</div></pre></td></tr></table></figure>
</li>
<li><p>添加项目组成员</p>
</li>
</ol>
<p><img src="https://minpeng.github.io//image/gitlab/add-members.png" alt="添加项目组成员"></p>
<ol>
<li><p>创建项目</p>
<p><img src="https://minpeng.github.io//image/gitlab/create-project.png" alt="创建项目"></p>
</li>
<li><p>添加项目成员</p>
<p><img src="https://minpeng.github.io//image/gitlab/add-project-members.png" alt="添加项目成员"></p>
</li>
</ol>
<p>5) <strong>设置人员</strong></p>
<blockquote>
<p>人员权限</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">Guest(游客):可以创建issue、发表评论，不能读写版本库</div><div class="line">Reporter(记者):可以克隆代码，不能提交</div><div class="line">Developer(开发者):可以克隆代码、开发、提交、push</div><div class="line">Master(主要维护者):可以创建项目、添加tag、保护分支、添加项目成员、编辑项目</div><div class="line">Owner(所属者):可以设置项目访问权限 - Visibility Level、删除项目、迁移项目、管理组成员</div></pre></td></tr></table></figure>
<blockquote>
<p>具体可看 <a href="https://docs.gitlab.com/ee/user/permissions.html" target="_blank" rel="external">https://docs.gitlab.com/ee/user/permissions.html</a></p>
</blockquote>
<h3 id="参考文档"><a href="#参考文档" class="headerlink" title="参考文档"></a>参考文档</h3><blockquote>
<p><a href="https://www.liaoxuefeng.com/wiki/896043488029600" target="_blank" rel="external">https://www.liaoxuefeng.com/wiki/896043488029600</a></p>
<p><a href="https://juejin.im/entry/5b1faf61f265da6e5b7635b6" target="_blank" rel="external">https://juejin.im/entry/5b1faf61f265da6e5b7635b6</a></p>
<p><a href="https://www.bootcss.com/p/git-guide/" target="_blank" rel="external">https://www.bootcss.com/p/git-guide/</a></p>
</blockquote>
</contents>
      
    </div>
    
  </div>
  
    
    <div class="copyright">
        <p><span>本文标题:</span><a href="/2019/11/05/git使用指南/">git使用指南</a></p>
        <p><span>文章作者:</span><a href="/" title="回到主页">min peng</a></p>
        <p><span>发布时间:</span>2019-11-05, 22:38:12</p>
        <p><span>最后更新:</span>2019-11-06, 20:23:20</p>
        <p>
            <span>原始链接:</span><a class="post-url" href="/2019/11/05/git使用指南/" title="git使用指南">https://minpeng.github.io/2019/11/05/git使用指南/</a>
            <span class="copy-path" data-clipboard-text="原文: https://minpeng.github.io/2019/11/05/git使用指南/　　作者: min peng" title="点击复制文章链接"><i class="fa fa-clipboard"></i></span>
            <script> var clipboard = new Clipboard('.copy-path'); </script>
        </p>
        <p>
            <span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" title="CC BY-NC-SA 4.0 International" target = "_blank">"署名-非商用-相同方式共享 4.0"</a> 转载请保留原文链接及作者。
        </p>
    </div>



    <nav id="article-nav">
        
            <div id="article-nav-newer" class="article-nav-title">
                <a href="/2020/03/21/java8Stream常用/">
                    java8Stream常用
                </a>
            </div>
        
        
            <div id="article-nav-older" class="article-nav-title">
                <a href="/2019/08/24/SpringBoot自定义配置文件区分环境/">
                    SpringBoot自定义配置文件区分环境
                </a>
            </div>
        
    </nav>

  
</article>

    <div id="toc" class="toc-article">
        <strong class="toc-title">文章目录</strong>
        
            <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#git-使用指南"><span class="toc-number">1.</span> <span class="toc-text">git 使用指南</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#git-介绍"><span class="toc-number">1.1.</span> <span class="toc-text">git 介绍</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#git-常用命令"><span class="toc-number">1.2.</span> <span class="toc-text">git 常用命令</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#tag-和-branche-的区别"><span class="toc-number">1.3.</span> <span class="toc-text">tag 和 branche 的区别</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#工作流程"><span class="toc-number">1.4.</span> <span class="toc-text">工作流程</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Eclipse-使用-git"><span class="toc-number">1.5.</span> <span class="toc-text">Eclipse 使用 git</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#idea-使用-git"><span class="toc-number">1.6.</span> <span class="toc-text">idea 使用 git</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#gitlab-项目管理"><span class="toc-number">1.7.</span> <span class="toc-text">gitlab 项目管理</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#参考文档"><span class="toc-number">1.8.</span> <span class="toc-text">参考文档</span></a></li></ol></li></ol>
        
    </div>
    <style>
        .left-col .switch-btn,
        .left-col .switch-area {
            display: none;
        }
        .toc-level-3 i,
        .toc-level-3 ol {
            display: none !important;
        }
    </style>

    <input type="button" id="tocButton" value="隐藏目录"  title="点击按钮隐藏或者显示文章目录">

    <script>
        yiliaConfig.toc = ["隐藏目录", "显示目录", !!"false"];
    </script>



    
<div class="share">
    
        <div class="bdsharebuttonbox">
            <a href="#" class="fa fa-twitter bds_twi" data-cmd="twi" title="分享到推特"></a>
            <a href="#" class="fa fa-weibo bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
            <a href="#" class="fa fa-qq bds_sqq" data-cmd="sqq" title="分享给 QQ 好友"></a>
            <a href="#" class="fa fa-files-o bds_copy" data-cmd="copy" title="复制网址"></a>
            <a href="#" class="fa fa fa-envelope-o bds_mail" data-cmd="mail" title="通过邮件分享"></a>
            <a href="#" class="fa fa-weixin bds_weixin" data-cmd="weixin" title="生成文章二维码"></a>
            <a href="#" class="fa fa-share-alt bds_more" data-cmd="more"></i></a>
        </div>
        <script>
            window._bd_share_config={
                "common":{"bdSnsKey":{},"bdText":"git使用指南　| Pengm　","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
        </script>
    

    
</div>







    
      <!-- 来必力City版安装代码 -->
	<div id="lv-container" data-id="city"  data-uid="MTAyMC8yODg4MS81NDUx">
		<script type="text/javascript">
	   (function(d, s) {
		   var j, e = d.getElementsByTagName(s)[0];

		   if (typeof LivereTower === 'function') { return; }

		   j = d.createElement(s);
		   j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
		   j.async = true;

		   e.parentNode.insertBefore(j, e);
	   })(document, 'script');
		</script>
	<noscript> 为正常使用来必力评论功能请激活JavaScript</noscript>
	</div>
	<!-- City版安装代码已完成 -->

    




    <div class="scroll" id="post-nav-button">
        
            <a href="/2020/03/21/java8Stream常用/" title="上一篇: java8Stream常用">
                <i class="fa fa-angle-left"></i>
            </a>
        

        <a title="文章列表"><i class="fa fa-bars"></i><i class="fa fa-times"></i></a>

        
            <a href="/2019/08/24/SpringBoot自定义配置文件区分环境/" title="下一篇: SpringBoot自定义配置文件区分环境">
                <i class="fa fa-angle-right"></i>
            </a>
        
    </div>

    <ul class="post-list"><li class="post-list-item"><a class="post-list-link" href="/2020/03/21/java8Stream常用/">java8Stream常用</a></li><li class="post-list-item"><a class="post-list-link" href="/2019/11/05/git使用指南/">git使用指南</a></li><li class="post-list-item"><a class="post-list-link" href="/2019/08/24/SpringBoot自定义配置文件区分环境/">SpringBoot自定义配置文件区分环境</a></li><li class="post-list-item"><a class="post-list-link" href="/2019/08/12/quill富文本编辑器自定义上传图片/">quill富文本编辑器自定义上传图片</a></li><li class="post-list-item"><a class="post-list-link" href="/2019/08/12/SpringBoot-WebSocket使用/">SpringBoot WebSocket使用</a></li><li class="post-list-item"><a class="post-list-link" href="/2019/08/12/SpringBoot事务解析/">SpringBoot事务解析</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/07/22/记两年工作总结/">记两年工作总结</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/06/22/读书笔记-疯狂Java/">读书笔记-疯狂Java</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/05/22/读书笔记-大型网站技术架构/">读书笔记-大型网站技术架构</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/05/22/shiro权限控制/">shiro权限控制</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/04/22/jdbc原生api批量插入数据库/">jdbc原生api批量插入数据库</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/03/22/序列化拷贝对象/">序列化拷贝对象</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/01/22/spring-memcache缓存注解配置/">spring+memcache缓存注解配置</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/07/16/java数字转换/">java数字转换</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/07/16/一年工作之感悟/">一年工作之感悟</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/07/09/Spring框架简单异步发送邮件/">Spring框架简单异步发送邮件</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/07/09/Mysql优化/">Mysql优化</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/05/29/linux/">Linux 生疏命令</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/04/03/Scrapy-xinmin/">Scrapy爬取新民网</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/03/03/java-demo/">java代码审查</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/12/23/StudySpark/">学习scala和spark的一些内容</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/12/17/我的第一篇博客/">我的第一篇博客：HBase</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/12/16/hello-world/">Hello World</a></li></ul>




    <script>
        
    </script>
</div>
      <footer id="footer">
    <div class="outer">
        <div id="footer-info">
            <div class="footer-left">
                <i class="fa fa-copyright"></i> 
                2016-2020 min peng
            </div>
            <div class="footer-right">
                <a href="http://hexo.io/" target="_blank" title="快速、简洁且高效的博客框架">Hexo</a>  Theme <a href="https://github.com/MOxFIVE/hexo-theme-yelee" target="_blank" title="简而不减 Hexo 双栏博客主题  v3.5">Yelee</a> by MOxFIVE <i class="fa fa-heart animated infinite pulse"></i>
            </div>
        </div>
        
            <div class="visit">
                
                    <span id="busuanzi_container_site_pv" style='display:none'>
                        <span id="site-visit" title="本站到访数"><i class="fa fa-user" aria-hidden="true"></i><span id="busuanzi_value_site_uv"></span>
                        </span>
                    </span>
                
                
                    <span>| </span>
                
                
                    <span id="busuanzi_container_page_pv" style='display:none'>
                        <span id="page-visit"  title="本页阅读量"><i class="fa fa-eye animated infinite pulse" aria-hidden="true"></i><span id="busuanzi_value_page_pv"></span>
                        </span>
                    </span>
                
            </div>
        
    </div>
</footer>

    </div>
    
<script data-main="/js/main.js" src="//cdn.bootcss.com/require.js/2.2.0/require.min.js"></script>

    <script>
        $(document).ready(function() {
            var iPad = window.navigator.userAgent.indexOf('iPad');
            if (iPad > -1 || $(".left-col").css("display") === "none") {
                var bgColorList = ["#9db3f4", "#414141", "#e5a859", "#f5dfc6", "#c084a0", "#847e72", "#cd8390", "#996731"];
                var bgColor = Math.ceil(Math.random() * (bgColorList.length - 1));
                $("body").css({"background-color": bgColorList[bgColor], "background-size": "cover"});
            }
            else {
                var backgroundnum = 5;
                var backgroundimg = "url(/background/bg-x.jpg)".replace(/x/gi, Math.ceil(Math.random() * backgroundnum));
                $("body").css({"background": backgroundimg, "background-attachment": "fixed", "background-size": "cover"});
            }
        })
    </script>





<div class="scroll" id="scroll">
    <a href="#" title="返回顶部"><i class="fa fa-arrow-up"></i></a>
    <a href="#comments" onclick="load$hide();" title="查看评论"><i class="fa fa-comments-o"></i></a>
    <a href="#footer" title="转到底部"><i class="fa fa-arrow-down"></i></a>
</div>
<script>
    // Open in New Window
    
        var oOpenInNew = {
            
             title: "a.article-title, .article-more-link a", 
            
             tags: ".article-tag a", 
             categories: ".article-category a, a.tag-list-link", 
             articleNav: "#article-nav a, #post-nav-button a", 
             archives: ".archive-article-title", 
             miniArchives: "a.post-list-link", 
            
             friends: "#js-friends a", 
             socail: ".social a" 
        }
        for (var x in oOpenInNew) {
            $(oOpenInNew[x]).attr("target", "_blank");
        }
    
</script>

<script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
  </div>
</body>
</html>